const http = require("http")
const fs = require("fs")

http.createServer((req, res) => {
  // 访问本地网页b.html
  if (req.url === "/b.html") {
    fs.readFile("./b.html", (err, data) => {
      if (err) {
        res.writeHead(404, {
          "Content-Type": "text/html"
        })
        res.end("404")
      } else {
        res.writeHead(200, {
          "Content-Type": "text/html"
        })
        res.end(data)
      }
    })
  }
}).listen(3000)
